package com.huadragon.marathondao.dao.impl;





import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.huadragon.marathondao.base.BaseDao;
import com.huadragon.marathondao.dao.inter.IAccountInfoDao;
import com.huadragon.marathondao.dao.inter.IMenuInfoDao;
import com.huadragon.marathonentity.common.page.PagerModel;
import com.huadragon.marathonentity.servicedomain.AccountInfoDomain;
import com.huadragon.marathonentity.servicedomain.MenuInfoDomain;

@Repository
public class MenuInfoDaoImpl implements IMenuInfoDao {
	@Autowired
	private BaseDao dao;

	public PagerModel selectPageList(MenuInfoDomain e) {
		return dao.selectPageList("AccountInfo.selectPageList",
				"AccountInfo.selectPageCount", e);
	}
	
	public MenuInfoDomain selectById(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	public List selectList(MenuInfoDomain e) {
		return dao.selectList("AccountInfo.selectList", e);
	}

	public MenuInfoDomain selectOne(MenuInfoDomain e) {
		return (MenuInfoDomain) dao.selectOne("AccountInfo.selectOne", e);
	}

	public int delete(MenuInfoDomain e) {
		return dao.delete("AccountInfo.delete", e);
	}

	public int update(MenuInfoDomain e) {
		return dao.update("AccountInfo.update", e);
	}

	public int deletes(int[] ids) {
		MenuInfoDomain e = new MenuInfoDomain();
		for (int i = 0; i < ids.length; i++) {
			e.setId(ids[i]);
			delete(e);
		}
		return 0;
	}

	public int insert(MenuInfoDomain e) {
		return dao.insert("AccountInfo.insert", e);
	}

	public int deleteById(int id) {
		return dao.delete("AccountInfo.deleteById", id);
	}

	public int selectCount(MenuInfoDomain e) {
		return dao.getCount("AccountInfo.selectCount", e);
	}

	public int insertList(List<MenuInfoDomain> list) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
	
	
	


	@Override
	public List getMenuListByUserID(int accountId) {
		/*String key=RedissCacheKey.Menu_Auth+accountId;
		List<MenuInfoDomain> result=redisService.get(key, List.class);
		if (result==null||result.size()==0) {
			List<MenuInfoDomain> list = getReadOnlySqlSessionUtil()
					.selectList(
							"IMenuInfoDao.getMenuListByUserID",
							accountId);
			redisService.set(key, list);
			return list;
		}
		

		return result;*/
		MenuInfoDomain menuInfo=new MenuInfoDomain();
		menuInfo.setAccountInfoId(accountId);
		return dao.selectList("MenuInfo.getMenuListByUserID",menuInfo );
	}

	@Override
	public List<MenuInfoDomain> getAuthSettingList(int userID) {
		/*return getReadOnlySqlSessionUtil()
				.selectList(
						"IMenuInfoDao.getAuthSettingList",
						userID);*/
		return null;
	}

	@Override
	public List getMenuListByRoleID(int roleID) {
		MenuInfoDomain menuInfo=new MenuInfoDomain();
		menuInfo.setRoleId(roleID);
		return dao.selectList("MenuInfo.getMenuListByRoleID",menuInfo );
	}
	
	@Override
	public List getMenuResourceByUserID(int userID) {
		MenuInfoDomain menuInfo=new MenuInfoDomain();
		menuInfo.setAccountInfoId(userID);
		return dao.selectList("MenuInfo.getMenuResourceByUserID",menuInfo );
	}

	@Override
	public List<MenuInfoDomain> getListMenuByParId(int parId) {
		/*return getReadOnlySqlSessionUtil()
				.selectList(
						"IMenuInfoDao.getListMenuByParId",
						parId);*/
		return null;
	}

	@Override
	public MenuInfoDomain getMenuById(int id) {
		/*return getReadOnlySqlSessionUtil()
				.selectOne(
						"IMenuInfoDao.getMenuById",
						id);*/
		return null;
	}

	@Override
	public boolean addMenu(MenuInfoDomain req) {
		return dao.insert("MenuInfo.addMenu", req) > 0;
	}
	
}
